(ns amsi.common.socket
  (:import (java.io BufferedReader InputStreamReader PrintWriter)))

; This code is based on example at http://nakkaya.com/2010/06/15/clojure-io-cookbook/

(defn open-socket
  "Open socket input and output streams and returns map with those values. Keys of map are :socket, :in and :out"
  [socket]
  (let[in (BufferedReader. (InputStreamReader. (.getInputStream socket))) out (PrintWriter. (.getOutputStream socket))]
    {
     :socket socket
     :in in
     :out out}))
     
  